package algorithm

import (
	"github.com/bgmp/config"
	"github.com/bgmp/handler"
	"github.com/bgmp/middleware"
	"github.com/bgmp/model"
	"github.com/bgmp/service"
	"github.com/gin-gonic/gin"
)

type Base struct{}

func DefaultHandler(c *gin.Context) {
	handler.Dispatch(c, Base{})
}

func (b Base) BgPredict(c *gin.Context, req *PredictBgRequest) []service.PredictResult {
	//fmt.Println(req.Time)
	userId := middleware.GetUserId(c)
	bgs := model.GetBgBefore(config.DB, userId, req.Time, 96)
	result := service.BgPredict(bgs)
	return result
}

// DTO
type PredictBgRequest struct {
	Time model.Time `json:"time"`
}

type BgVo struct {
	Time  model.Time `json:"time"`
	Value float32    `json:"value"`
}
